package Test;

/**
 * @leiwenkang 2018-01-22 17:53.
 */
public class IsContinous {
    public static void main(String[] args) {
        int[] array = {1, 2, 3, 4, 6};
        System.out.println(isContinous(array));
    }

    public static boolean isContinous(int[] array){
        if (array == null || array.length == 0){
            return false;
        }

        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;

        for (int i = 0; i < array.length; i++) {
            if (array[i] != 0) {
                if (array[i] < min) {
                    min = array[i];
                }
                if (array[i] > max) {
                    max = array[i];
                }
            }
        }
        if (max - min <= array.length - 1) {
            return true;
        } else {
            return false;
        }
    }
}
